from enum import StrEnum, Enum


class ProtocolType(StrEnum):
    TCP = "TCP"
    RTU = "RTU"
    RTU_OVER_TCP = "RTU_OVER_TCP"


class TcpConfig:
    host: str
    port: int
    protocol_type: ProtocolType
    framer = "tcp"

    def __init__(self, host: str, port: int, protocol_type: ProtocolType):
        self.host = host
        self.port = port
        self.protocol_type = protocol_type


class RtuConfig:
    port: str
    baudrate: int = 9600
    parity: str = 'N'
    stopbits: int = 1
    bytesize: int = 8
    timeout: float = 1.0
    protocol_type: ProtocolType = ProtocolType.RTU

    def __init__(self, port: str, baudrate: int = 9600, parity: str = 'N', stopbits: int = 1, bytesize: int = 8,
                 timeout: float = 1.0, protocol_type: ProtocolType = ProtocolType.RTU):
        self.port = port
        self.baudrate = baudrate
        self.parity = parity
        self.stopbits = stopbits
        self.bytesize = bytesize
        self.timeout = timeout
        self.protocol_type = protocol_type
